/*
day467 
2020.12.7 
*/
#include<vector>
#include<queue>
#include<iostream>
using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Solution {
public:
    vector<ListNode*> listOfDepth(TreeNode* tree) {
		queue<TreeNode *> que;
		vector<ListNode*> res;
		que.push(tree);
		ListNode *head=new ListNode(0),*p;
		TreeNode *tem=nullptr;
		while(!que.empty())
		{
			int size=que.size();
			head->next=nullptr;
			p=head;
			for(int i=0;i<size;++i)
			{
				tem=que.front();
				que.pop();
				if(tem->left) que.push(tem->left);
				if(tem->right) que.push(tem->right);
				p->next=new ListNode(tem->val);
				p=p->next;
			}
			res.push_back(head->next);
		} 
		
		return res;
    }
};

int main()
{
	return 0;
}
